/* GUI CONVERTED from rqjmt.p (converter v1.75) Sat Aug 12 23:12:30 2000 */
/* rqjmt.p - Job Maintenance                                                */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.             */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                       */
/*K1Q4*/ /*V8:RunMode=Character,Windows                                     */
/* REVISION 8.5       LAST MODIFIED: 04/15/97  BY: *J1Q2* Patrick Rowan     */
/* REVISION 8.6       LAST MODIFIED: 05/20/98  BY: *K1Q4* Alfred Tan        */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00 BY: *N0KP* myb                */


/*!
 ----------------------------------------------------------------------------
 DESCRIPTION: ADDS/MODS/DELETES requisition jobs.
              Supports the multi-line Purchase Requisition Module of MFG/PRO.

 Notes:
 ============================================================================
 !*/

          /* DISPLAY TITLE */
      {mfdtitle.i "b+ "}

          /* LOGICALS */
          define variable del-yn    like mfc_logical no-undo
                    initial no.
      define new shared variable task as character format "X(8)".
      define new shared variable del_ok like mfc_logical.

          /* FRAME A: SELECTION FORM */
          
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
            
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
rqj_job      colon 25
        skip(1)
            rqj_desc     colon 25
            rqj_start    colon 25
            rqj_end      colon 25
           SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



          /* SET EXTERNAL LABELS */
          setFrameLabels(frame a:handle).

          /* DISPLAY */
      view frame a.

      mainloop:
          repeat with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.


         /* PROMPT-FOR KEYS */

             prompt-for
        rqj_job
        with frame a editing:

                 /* FIND NEXT/PREVIOUS RECORD */
         {mfnp.i rqj_mstr rqj_job rqj_job rqj_job
                 rqj_job rqj_job}
                 if recno <> ? then
            display
               rqj_job
               rqj_desc
               rqj_start
               rqj_end
               with frame a.
             end.  /* prompt-for */

         if input rqj_job = "" then do:
             {mfmsg.i 40 3}
         undo, retry.
         end.

         task = input rqj_job.

             /* ADD/MOD/DELETE  */
         find rqj_mstr where
        rqj_job = input rqj_job no-error.
             if not available rqj_mstr then do:

                {mfmsg.i 1 1}      /* ADDING NEW RECORD */
                create rqj_mstr.
                assign
            rqj_job.
            if recid(rqj_mstr) = -1 then.

             end.  /* if not available rqj_mstr */

         display
            rqj_job
            rqj_desc
            rqj_start
            rqj_end
        with frame a.

             ststatus = stline[2].
             status input ststatus.
         del-yn = no.

         setloop1:
         do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

        set
           rqj_desc
           rqj_start
           rqj_end
           go-on("F5" "CTRL-D")
           with frame a.

        /* DELETE */
                if lastkey = keycode("F5") or lastkey = keycode("CTRL-D")
        then do:
           /* CHECK FOR ACTIVE APPROVERS WITH THIS JOB CODE */
           /* ACTIVE APPROVERS HAVE END EFFECTIVITY AFTER TODAY
              OR HAVE NO END EFFECTIVITY. */
                   find first rqa_mstr where
              (rqa_job = rqj_job and
              (rqa_end > today or rqa_end = ?))
              no-lock no-error.
           if available rqa_mstr then do:
               {mfmsg.i 1788 4}
               /* CANNOT DELETE APPR DETAILS RECORDS EXIST */
               undo, leave setloop1.
           end.

           /* DELETE */
                   del-yn = yes.
                   {mfmsg01.i 11 1 del-yn}  /* CONFIRM DELETE */
                   if del-yn = no then undo setloop1.
                end.

                if del-yn then do:
           /* OK TO DELETE */
           delete rqj_mstr.
           clear frame a.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
           del-yn = no.
           next mainloop.
                end.

        /* DATE RANGE CHECK */
                if (rqj_start <> ? and rqj_end <> ?) and
            rqj_start > rqj_end then do:
           {mfmsg.i 123 3}
           /* END DATE CANNOT BE BEFORE START DATE */
           next-prompt rqj_end.
           undo, retry.
                end.

             end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* setloop1 */

          end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* mainloop repeat */

          status input.
